from django.db import models

from utils.constants import IS_INVOICE_CHOICES


class InvoiceList(models.Model):
    """ 报销 """
    created_at = models.DateField('日期')
    project = models.CharField('项目', max_length=255)
    amount = models.DecimalField('金额', max_digits=32, decimal_places=2)
    is_invoice = models.SmallIntegerField("是否有发票", choices=IS_INVOICE_CHOICES, null=False, blank=False)
    reimbursement = models.CharField('报销人', max_length=200)
    approver = models.ImageField('审批人', upload_to='%Y%m/shenpiren', null=True, blank=True,
                                 help_text='<span style="color:red">钉钉截图</span>')
    remark = models.TextField('备注', max_length=256, null=True, blank=True)

    def __str__(self):
        return self.project

    class Meta:
        db_table = 'invoice_list'
        verbose_name = '开票报销'
        verbose_name_plural = verbose_name
        ordering = ['-created_at']
